Skip to content

Get-DbaAgRingBuffer - Add command for HADR ring buffer diagnostics#10282

Merged
potatoqualitee merged 2 commits into
developmentfrom
claude/issue-9823-20260322-1013
Mar 28, 2026
Merged

Get-DbaAgRingBuffer - Add command for HADR ring buffer diagnostics#10282
potatoqualitee merged 2 commits into
developmentfrom
claude/issue-9823-20260322-1013

Conversation

@andreasjordan
Copy link
Copy Markdown
Collaborator

Implements Get-DbaAgRingBuffer to expose the internal HADR ring buffers for Always On AG diagnostics.

Queries sys.dm_os_ring_buffers for the four HADR-specific types: RING_BUFFER_HADRDBMGR_API, RING_BUFFER_HADRDBMGR_STATE, RING_BUFFER_HADRDBMGR_COMMIT, and RING_BUFFER_HADR_TRANSPORT_STATE.

Returns raw XML records alongside metadata so callers have full access to the diagnostic data without fragile type-specific XML parsing.

Closes #9823

Generated with Claude Code

Implements Get-DbaAgRingBuffer to query sys.dm_os_ring_buffers for the
four HADR-specific ring buffer types used in Always On AG diagnostics:
RING_BUFFER_HADRDBMGR_API, RING_BUFFER_HADRDBMGR_STATE,
RING_BUFFER_HADRDBMGR_COMMIT, and RING_BUFFER_HADR_TRANSPORT_STATE.

Returns raw XML records alongside metadata (EventTime, RingBufferType,
RecordId) so callers have full access to the unsupported-but-useful
diagnostic data without brittle type-specific XML parsing.

Requires SQL Server 2012+ (MinimumVersion 11) as Always On was
introduced in that release.

Closes #9823

(do Get-DbaAgRingBuffer)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@andreasjordan andreasjordan marked this pull request as ready for review March 22, 2026 11:46
@ReeceGoding
Copy link
Copy Markdown
Contributor

Looks good to me. The timestamp stuff looks a bit weird, but it made sense once I remembered the definition of the timestamp column.

I wonder if a CollectionMinutes parameter is worth adding for consistency with Get-DbaCpuRingBuffer? I'm not decided on that.

@andreasjordan
Copy link
Copy Markdown
Collaborator Author

@claude please have a look at the last comment. I think we should add CollectionMinutes for consistency with Get-DbaCpuRingBuffer.

@claude
Copy link
Copy Markdown

claude Bot commented Mar 22, 2026

Claude finished @andreasjordan's task in 1m 31s —— View job


Adding CollectionMinutes Parameter

  • Read existing Get-DbaAgRingBuffer.ps1 and Get-DbaCpuRingBuffer.ps1
  • Add CollectionMinutes parameter to Get-DbaAgRingBuffer.ps1
  • Update tests to include CollectionMinutes in expected parameters
  • Commit and push changes

Done. Added [int]$CollectionMinutes = 60 matching the Get-DbaCpuRingBuffer pattern. The SQL query now filters with:

WHERE DATEADD(ms, -1 * ($currentTimestamp - [timestamp]), GETDATE()) > DATEADD(MINUTE, -$CollectionMinutes, GETDATE())

Also added a .PARAMETER CollectionMinutes doc block and a new .EXAMPLE showing -CollectionMinutes 240 usage.
|

… with Get-DbaCpuRingBuffer

(do Get-DbaAgRingBuffer)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@potatoqualitee
Copy link
Copy Markdown
Member

awesome, thank you both 💯

@potatoqualitee potatoqualitee merged commit c82ae19 into development Mar 28, 2026
14 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-9823-20260322-1013 branch March 28, 2026 07:21
potatoqualitee added a commit that referenced this pull request Apr 10, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the internal HA/DR ring buffers, for better health information about Always On availability groups

3 participants